home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CICA Windows Explosion!
/
The CICA Windows Explosion! - Disc 2.iso
/
programr
/
ole2book.zip
/
CHAP07.ZIP
/
CHAP07
/
DATATRAN
/
DATAOBJ.H
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-23
|
5KB
|
157 lines
/*
* DATAOBJ.H
*
* Classes that implement the Data Transfer Object.
*
* Copyright (c)1993 Microsoft Corporation, All Right Reserved
*
* Kraig Brockschmidt, Software Design Engineer
* Microsoft Systems Developer Relations
*
* Internet : kraigb@microsoft.com
* Compuserve: >INTERNET:kraigb@microsoft.com
*/
#ifndef _DATAOBJ_H_
#define _DATAOBJ_H_
#include <windows.h>
#include <ole2.h>
#include <bookguid.h>
//Type for an object-destroyed callback
typedef void (FAR PASCAL *LPFNDESTROYED)(void);
/*
* Structure to describe a specific rendering that our user wants
* us to maintain.
*/
typedef struct __far tagRENDERING
{
FORMATETC fe; //The format
STGMEDIUM stm; //The actual data
LPUNKNOWN pUnkOrg; //The real owner
} RENDERING, FAR * LPRENDERING;
/*
* The DataObject object is implemented in its own class with its own
* IUnknown to support aggregation. It contains one CImpIDataObject
* object that we use to implement the externally exposed interfaces.
*/
//DATAOBJ.CPP
class __far CDataObject : public IUnknown
{
//Make any contained interfaces your friends so they can get at you
friend class CImpIDataObject;
protected:
ULONG m_cRef; //Object reference count.
LPUNKNOWN m_punkOuter; //Cont. Unk. for aggregation
LPFNDESTROYED m_pfnDestroy; //Function to call on closure.
HWND m_hList; //Listbox of RENDERINGs
//Contained interface implemetation
LPDATAOBJECT m_pIDataObject;
public:
CDataObject(LPUNKNOWN, LPFNDESTROYED);
~CDataObject(void);
BOOL FInit(void);
void Purge(void);
//Non-delegating object IUnknown
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
};
typedef CDataObject FAR * LPCDataObject;
/*
* Interface implementations for the CDataObject object.
*/
class __far CImpIDataObject : public IDataObject
{
private:
ULONG m_cRef; //Interface reference count.
LPCDataObject m_pObj; //Back pointer to the object.
LPUNKNOWN m_punkOuter; //Controlling unknown for delegation
public:
CImpIDataObject(LPCDataObject, LPUNKNOWN);
~CImpIDataObject(void);
//IUnknown members that delegate to m_punkOuter.
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
//IDataObject members
STDMETHODIMP GetData(LPFORMATETC, LPSTGMEDIUM);
STDMETHODIMP GetDataHere(LPFORMATETC, LPSTGMEDIUM);
STDMETHODIMP QueryGetData(LPFORMATETC);
STDMETHODIMP GetCanonicalFormatEtc(LPFORMATETC, LPFORMATETC);
STDMETHODIMP SetData(LPFORMATETC, STGMEDIUM FAR *, BOOL);
STDMETHODIMP EnumFormatEtc(DWORD, LPENUMFORMATETC FAR *);
STDMETHODIMP DAdvise(FORMATETC FAR *, DWORD, LPADVISESINK, DWORD FAR *);
STDMETHODIMP DUnadvise(DWORD);
STDMETHODIMP EnumDAdvise(LPENUMSTATDATA FAR *);
};
/*
* IEnumFORMATETC object that is created from IDataObject::EnumFormatEtc.
* This object lives on its own, that is, QueryInterface only knowns
* IUnknown and IEnumFormatEtc, nothing more. We still use an outer
* unknown for reference counting, because as long as this enumerator
* lives, the data object should live, thereby keeping the application up.
*/
class __far CEnumFormatEtc : public IEnumFORMATETC
{
private:
ULONG m_cRef; //Object reference count.
LPUNKNOWN m_punkRef; //IUnknown for reference counting.
LPFORMATETC m_prgfe; //FORMATETC list.
ULONG m_iCur; //Current element.
ULONG m_cItems;
public:
CEnumFormatEtc(LPUNKNOWN);
~CEnumFormatEtc(void);
BOOL FInit(HWND);
//IUnknown members that delegate to m_punkOuter.
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
//IEnumFORMATETC members
STDMETHODIMP Next(ULONG, LPFORMATETC, ULONG FAR *);
STDMETHODIMP Skip(ULONG);
STDMETHODIMP Reset(void);
STDMETHODIMP Clone(IEnumFORMATETC FAR * FAR *);
};
typedef CEnumFormatEtc FAR * LPCEnumFormatEtc;
#endif //_DATAOBJ_H_